<div class='temp_body'>
	<div id="{{item.id}}" style='text-align:center'>
		{% include item.query %}
		<button class="jxd_btn" clickType=0 callFunc="click:{{item.id}}Handle.qry" >搜索</button>	
		<button class="jxd_btn" clickType=0 callFunc="click:{{item.id}}Handle.add" >{{item.name}}</button>
	</div>
	<div style='border: 1px solid #E0C5A8;border-radius: 8px;overflow:auto'>
		<div id="{{item.id}}_sort" class='normalQryHead'>
			<span class='total'>共0条记录</span>
			<select onchange="{{item.id}}_sort(this.value)">
				<option value=''>默认排序</option>
			</select>
		</div>
		<div id="{{item.id}}_table" class='fileTable'>
			<div id='tableBody'></div>
		</div>
	</div>
</div>
<script>
function {{item.id}}_sort(val){
	yanhx.exec("{{item.id}}Handle.sort",val);
}
function {{item.id}}_fill(ret){
	yanhx.exec("{{item.id}}Handle.fillTable",ret);
}
function {{item.id}}_scroll(){
	yanhx.exec("{{item.id}}Handle.scrollQry");
}
yanhx.addCommon("load",function(){
	//head 需定义参数param 普通查询包含 sort head template 
	{% include item.head %}
	yanhx.exec("{{item.id}}Handle.init",param);
	yanhx.exec("{{item.id}}Handle.qry");
	yanhx.exec("scrollHandle.add",{{item.id}}_scroll)
});
yanhx.addComponent("{{item.id}}Handle",{
	bean:null,
	clean:false,
	canPage:true,
	init:function(param){
		this.tableDiv=$("#{{item.id}}_table");
		this.table=this.tableDiv.children("#tableBody");
		this.table.listTable({
			//头配置
			curCfg:param.head,
			//模板
			curTemp:$(param.temp)
		});	
		if(param.sort){
			var t=$("#{{item.id}}_sort");
			var sel=t.find("select");
			$(param.sort).each(function(){
				$("<option value="+this.id+">"+this.name+"</option>").appendTo(sel);
			});
		}
	},
	qry:function(){
		var bean=$("#{{item.id}}").getBean();		
		this.bean=bean;
		this.bean.page=1;
		this.bean.pageSize={{item.pageSize}};
		this.bean.qryTotal="y";
		this.canPage=true;
		this.clean=true;
		this.doQuery();	
	},
	doQuery:function(){
		$.java({
			action:'{{item.action}}',
			param:this.bean,
			showload:true,
			callback:{{item.id}}_fill
		});
	},
	add:function(){
		$(common.{{item.id}}).modelWin({
			title:'{{item.name}}',
			valid:'{{item.id}}_valid'
		});
	},
	sort:function(val){
		this.clean=true;
		this.bean.qryTotal=null;
		this.bean.page=1;
		this.canPage=true;
		this.bean.sortBy=val;
		this.doQuery();
	},
	scrollQry:function(){
		if(this.canPage){
			this.bean.page++;
			this.clean=false;
			this.bean.qryTotal=null;
			this.canPage=false;
			this.doQuery();
		}else{
			//不处理 滚动分页需注意同步问题
		}
	},
	fillTable:function(data){
		if(data.total||data.total==0){
			$("#{{item.id}}_sort").find(".total").text("共"+data.total+"条记录");
		}
		if(data.rows&&data.rows.length){
			this.canPage=true;
		}else{
			this.canPage=false;
		}
		this.table.listTable({
			clean:this.clean,
			data:data.rows
		});
	},
	view:function(){
		var data=tableHandle.exec({
			table:this.table,
			func:'getId',
			data:$src()
		});
		$.java({
			action:'{{item.id}}.view',
			param:{id:data},
			callback:function(){
			
			}
		});
	},
	download:function(){
		var data=tableHandle.exec({
			table:this.table,
			func:'getId',
			data:$src()
		});
		$.java({
			action:'{{item.id}}.download',
			param:{id:data},
			callback:function(ret){
				location.href=ret.mes;
			}
		});
	}	
});
</script>